<?php 

require "vuelta.config.php";

if (isset($_POST['email']) && ($_POST['text'])){
  $to = "mickfreeze@gmail.com";
  $subject = "Vuelta tourspel contact formulier";
  $message = "Bericht van ". $_POST['first_name']. " " . $_POST['last_name'] . " \n" . $_POST['text']; 
  $from = $_POST['email'];
  $headers = "From:" . $from;
  $mailed = mail($to,$subject,$message,$headers);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Vuelta Tourspel - Contact</title>

  <!-- stylesheet hier -->

  <?php Vuelta::css('css/generic.css');?>
  <?php Site::css('header');?>
  <?php Vuelta::css('css/contact.css');?>
</head>

<body>
  <?php Site::load('header');?>
  <form class="thin-border content" action="contact.php" method="POST">
      <?php if(isset($mailed)){
              if($mailed){
      ?><p class="message">Uw bericht is doorgestuurd</p><?php
              } else {
      ?><p class="message">Uw bericht kan op het moment niet worden verstuurd. Probeer het later nog eens</p><?php
              }
      } ?>
      <p><label>Email: <input type="email" name="email" required="required"></label></p>
      <p><label>Voornaam: <input name="first_name" required="required"></label></p>
      <p><label>Achternaam: <input name="last_name" required="required"></label></p>
      <p><label>Uw vraag/suggestie: <textarea name="text" ></textarea></label></p>
      <p><button>Submit</button></p>
  </form>
</body>
</html>



